<html xmlns:concordion="http://www.concordion.org/2007/concordion">
<head>
<link href="../../../../concordion.css" rel="stylesheet" type="text/css" />
<title>Exceptions</title>
</head>
<body>

    <h1>Exceptions</h1>

    <p>
        If an exception (or any Throwable) occurs during processing, the 
        exception message is displayed along with a stack trace. The stack trace's
        visibility can be toggled by a button. The expected value is wrapped in
        a span, and the actual value is shown as the exception message. 
    </p>    
    
    <div class="example">        
    
        <h3>Example</h3>

        <p>
            Assuming a <code>Throwable</code> with
            the message "<code concordion:set="#errorMessage">My error message</code>",
            the expression "<code concordion:set="#expr">myMethod()</code>",
            and the following stack trace elements:
        </p>

        <table concordion:execute="addStackTraceElement(#declarer, #method, #filename, #lineNumber)">
            <tr>
                <th concordion:set="#declarer">Declaring Class</th>
                <th concordion:set="#method">Method</th>
                <th concordion:set="#filename">Filename</th>
                <th concordion:set="#lineNumber">Line Number</th>
            </tr>
            <tr>
                <td>com.mycompany.MyClass</td>  
                <td>myMethod</td>   
                <td>MyClass.java</td>   
                <td>4</td>  
            </tr>
            <tr>
                <td>sun.reflect.NativeMethodAccessorImpl</td>   
                <td>invoke0</td>    
                <td>null</td>   
                <td>1</td>  
            </tr>
            <tr>
                <td>junit.framework.TestCase</td>   
                <td>runTest</td>    
                <td>TestCase.java</td>  
                <td>164</td>    
            </tr>
        </table>

        <p>is reported against the following element:</p>

<pre class="html" concordion:set="#snippet">
&lt;p&gt;some text&lt;/p&gt;
</pre>

        <p>We expect this output:</p>

<pre class="html" concordion:assertEquals="markAsException(#snippet, #expr, #errorMessage)">
&lt;p&gt; _
&lt;span class="failure"&gt; _
&lt;del class="expected"&gt;some text&lt;/del&gt; _
&lt;/span&gt; _
&lt;span class="exceptionMessage"&gt;My error message&lt;/span&gt; _
&lt;input class="stackTraceButton" id="stackTraceButton1" type="button" _
 onclick="javascript:toggleStackTrace('1')" value="View Stack" /&gt; _
&lt;span class="stackTrace" id="stackTrace1"&gt; _
&lt;p&gt;While evaluating expression: &lt;code&gt;myMethod()&lt;/code&gt;&lt;/p&gt; _
&lt;span class="stackTraceExceptionMessage"&gt;java.lang.Throwable: My error message&lt;/span&gt; _
&lt;span class="stackTraceEntry"&gt;at com.mycompany.MyClass.myMethod (MyClass.java:4)&lt;/span&gt; _
&lt;span class="stackTraceEntry"&gt;at sun.reflect.NativeMethodAccessorImpl.invoke0 (Unknown Source)&lt;/span&gt; _
&lt;span class="stackTraceEntry"&gt;at junit.framework.TestCase.runTest (TestCase.java:164)&lt;/span&gt; _
&lt;/span&gt; _
&lt;/p&gt;
</pre>


    </div>

    <h2>Further Details</h2>
    
    <ul>
        <li><a href="TODO.html">TODO: Where is the toggleStackTrace() script defined?</a></li>
        <li><a href="TODO.html">TODO: How are multiple stack traces dealt with?</a></li>
        <li><a href="TODO.html">TODO: What if the item is empty or contains only whitespace?</a></li>
        <li><a href="TODO.html">TODO: What if the error message is null?</a></li>
        <li><a href="TODO.html">TODO: What happens for &lt;a&gt; elements?</a></li>
        <li><a href="TODO.html">TODO: Any special handling for exceptions with a 'cause'?</a></li>
        <li><a href="TODO.html">TODO: Any special handling for SQL exceptions?</a></li>
        <li><a href="TODO.html">TODO: Is the stack trace filtered at all?</a></li>
    </ul>        

</body>
</html>